<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%-- 导入采用JSP方式定义的标签，其中的 tagdir 就是 .tag 文件所在的目录 --%>
<%@ taglib prefix="k" tagdir="/WEB-INF/tags" %>

<html>
    <head>
        <title>话题列表</title>
        <link rel="icon" href="${pageContext.request.contextPath}/images/kaifamiao.jpg" type="image/x-icon">
        <link rel="shortcut icon" href="${pageContext.request.contextPath}/images/kaifamiao.jpg" type="image/x-icon" media="screen">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="${pageContext.request.contextPath}/styles/list.css">
    </head>
    <body>

        <%-- 利用JSP标准动作实现包含操作 --%>
        <jsp:include page="/WEB-INF/pages/commons/status.jsp"></jsp:include>

        <jsp:include page="/WEB-INF/pages/commons/head.jsp"></jsp:include>

        <c:if test="${ empty pagination.dataList }">
            <div class="container topic-list">
                <p>暂无话题</p>
                <a href="${pageContext.request.contextPath}/topic/publish/page">点此发布新话题</a>
            </div>
        </c:if>

        <c:if test="${ not empty pagination.dataList }">
            <div class="container topic-list">
                <h3>我发布的话题</h3>
                <div class="row topic-title">
                    <span class="col-1">序号</span>
                    <span class="col-5">标题</span>
                    <span class="col-3">发布时间</span>
                    <span class="col-3"></span>
                </div>
                <c:forEach items="${ pagination.dataList }" var="t" varStatus="s">
                <div class="row topic-item ${ s.count % 2 == 0 ? 'even' : 'odd' }">
                    <span class="col-1">${ s.count }</span>
                    <span class="col-5">
                        <a href="/topic/detail?id=${ t.id }">${ t.title }</a>
                    </span>
                    <span class="col-3">${ t.publishTime }</span>
                    <span class="col-3">
                        <a href="/topic/detail?id=${ t.id }" class="btn btn-primary btn-sm">详情</a>
                        <a href="/topic/update/${ t.id }" class="btn btn-primary btn-sm">修改</a>
                        <a href="/topic/remove/${ t.id }" class="btn btn-primary btn-sm">删除</a>
                    </span>
                </div>
                </c:forEach>
            </div>
            <%-- 使用自定义标签(采用JSP语法定义的标签) --%>
            <k:pager current="${ pagination.current }" total="${ pagination.total }" uri="/topic/list/mine"></k:pager>
        </c:if>

        <jsp:include page="/WEB-INF/pages/commons/foot.jsp"></jsp:include>
    </body>
</html>
